package com.heykui.restfulcrud.result;

public class Result{

    public Object data;
    public Integer errcode;
    public String msg;


    private Result(CodeMsg codeMsg, Object data){
        this.msg     = codeMsg.getMsg();
        this.errcode = codeMsg.getCode();
        this.data    = data;
    }
    
    public Result(Integer code, String msg){
        this.errcode = code;
        this.msg     = msg;
    }
    public Result(Integer code, String msg, Object data){
        this.errcode = code;
        this.msg     = msg;
        this.data = data;
    }

    public static Result suss(Object data){
        return new Result(CodeMsg.SUSS, data);
    }
    public static Result suss(){
        return suss(null);
    }

    public static Result fail() {
        return new Result(CodeMsg.FAIL, null);
    }
    public static Result fail(String msg) {
        return new Result(CodeMsg.FAIL.getCode(), msg);
    }

    public static Result error() {
        return new Result(CodeMsg.ERR, null);
    }
    public static Result error(String msg) {
        return new Result(CodeMsg.ERR.getCode(), msg);
    }
}